package com.tanguy.user.ui.trip.activity.choice

import android.app.Activity
import android.content.Intent
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import com.tanguy.user.Const
import com.tanguy.user.R
import com.tanguy.user.base.ImmersionTitleActivity
import com.tanguy.user.bean.station.StationBean
import com.tanguy.user.ui.trip.activity.adapter.CityServiceAdapter
import org.jetbrains.anko.find

/**
 * Created by dab on 2017/11/21 0021 11:23
 * 服务城市
 */
class ServiceCityActivity : ImmersionTitleActivity() {
    override fun setContentViewRes(): Int = R.layout.activity_service_city
    override fun initView() {
        super.initView()
        title = "服务城市"
        val stationBean = intent.getParcelableExtra<StationBean>(Const.IntentCode.CITY_BEAN)
        find<RecyclerView>(R.id.rv_content).apply {
            val cityServiceAdapter = CityServiceAdapter(stationBean.city)
            adapter = cityServiceAdapter
            layoutManager = LinearLayoutManager(this@ServiceCityActivity)
            cityServiceAdapter.setOnItemClick {
                _, _, data ->
                setResult(Activity.RESULT_OK, Intent()
                        .putExtra(Const.IntentCode.CITY_NAME, data.name)
                        .putExtra(Const.IntentCode.CITY_ID, data.id.toString())
                )
                finish()

            }
        }
    }
}